<template>
	<view>
		<city-select
			@cityClick="cityClick"
			:formatName="formatName"
			:activeCity="activeCity"
			:hotCity="hotCity"
			:obtainCitys="obtainCitys"
			:isSearch="true"
			ref="citys"
		></city-select>
	</view>
</template>

<script >
import citys from './citys.js'
import citySelect from '@/pages/Lochig/city-select/city-select.vue'
export default {
	data() {
		return {
			//需要构建索引参数的名称（注意：传递的对象里面必须要有这个名称的参数）
			formatName: 'title',
			//当前城市
			activeCity: {
				id: 1,
				title: '重庆'
			},
			//热门城市
			hotCity: [
				{
					id: 0,
					title: '重庆'
				},
				{
					id: 1,
					title: '成都'
				},
				{
					id: 2,
					title: '深圳'
				},
				{
					id: 3,
					title: '广州'
				},
				{
					id: 4,
					title: '南京'
				},
				
			],
			//显示的城市数据
			obtainCitys: [
				{
					id: 0,
					title: '重庆'
				},
				{
					id: 1,
					title: '成都'
				},
				{
					id: 2,
					title: '深圳'
				},
				{
					id: 3,
					title: '广州'
				}
			]
		}
	},
	components: {
		citySelect
	},
	onLoad() {

		//动态更新数据
		setTimeout(() => {
			//修改数据格式
			this.formatName = 'cityName'
			//修改当前城市
			this.activeCity = {
				cityName: '重庆',
				cityCode: 110100
			}
			//修改热门城市
			this.hotCity = [
				{
					cityName: '重庆',
					cityCode: 110100
				},
				{
					cityName: '成都',
					cityCode: 510100
				},
				{
					cityName: '北京',
					cityCode: 110102
				},
			
				{
					cityName: '深圳',
					cityCode: 440300
				}
			]
			//修改构建索引数据
			this.obtainCitys = citys
			// uni.showToast({
			// 	icon: 'none',
			// 	title: '更新数据成功',
			// 	// #ifdef MP-WEIXIN
			// 	duration: 3000,
			// 	// #endif
			// 	mask: true
			// })
		}, 100)
	},
	methods: {
		cityClick(item) {
			// uni.$emit('cityName', item.cityName),
		
			uni.redirectTo({
				url:`/pages/Lochig/cotticoffee/Selectstore?city=${item.cityName}`
			})
			// uni.showToast({
			// 	icon: 'none',
			// 	title: 'item: ' + JSON.stringify(item),
			// 	// #ifdef MP-WEIXIN
			// 	duration: 3000,
			// 	// #endif
			// 	mask: true
			// })
		}
	}
}
</script>

<style></style>
